package com.zhdl.modules.demo.DCHTProcess;

import com.zhdl.modules.process.dto.ProcessBean;
import com.zhdl.modules.process.task.CustomizeTask;
import com.zhdl.modules.process.task.DynamicTask;
import com.zhdl.modules.process.verify.PlCBitValueVerify;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class RobotTestProcess {
    @Resource
    DynamicTask dynamicTask;
    @Resource
    CHTRobotInterface chtRobotInterface;
    public void startProcessByStep(float step){
        ProcessBean processBean = getProcessByStep(step,0);
        processBean.getProcessDo().doSomeThing();
        dynamicTask.startTask(new CustomizeTask(processBean),500);
    }
    public ProcessBean getProcessByStep(float step,int number){
        ProcessBean processBean = new ProcessBean(chtRobotInterface.getDescByStep(step),number);
        processBean.addDoSomeThing(() -> chtRobotInterface.moveByStep(step))
                .addProcessVerify(new PlCBitValueVerify(chtRobotInterface,chtRobotInterface.getVStrByStep(step)));
        return processBean;
    }
}
